#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll rr() {
    ll s = 0, w = false, c = getchar();
    for (; !isdigit(c); c = getchar())
        w = w || c == '-';
    for (; isdigit(c); c = getchar())
        s = s * 10 + c - '0';
    return w ? -s : s;
}

// END OF HEADER

int main() {
    int n = rr();
    vector<int> x(n), y(n);
    for (int i = 0; i < n; i++) {
        x[i] = rr(), y[i] = rr();
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    for (int i = 0; i < n; i++) {
        x[i] -= i;
    }
    sort(x.begin(), x.end());
    int midy = y[n / 2], midx = x[n / 2];
    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans += abs(midy - y[i]) + abs(midx - x[i]);
    }
    printf("%d", ans);
}